package bs_z7;

public class Writer extends Thread{

	protected static int currentId = 0;
	
	
	private Document doc;
	public final int id;
	
	public Writer(Document doc) throws InterruptedException {
		this.doc = doc;
		this.id = currentId++;
		System.out.println("Writer No. " + id + " has been created");
		this.start();
	}
	
	public void write(){
		System.out.println("Writer No. :" + id + " has entered the document");
		System.out.println("Writer No. :" + id + " has left the document");
	}
	
	public void run(){
		try {
			doc.writer(this);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
